<?php

namespace App\Admin\Forms;

use App\Helpers\Lib\RedisService;
use App\Models\TongUser;
use App\Models\TongUserProfit;
use App\Models\TongUserWithdrawal;
use Dcat\Admin\Traits\LazyWidget;
use Dcat\Admin\Widgets\Form;
use Illuminate\Support\Facades\DB;

class StatusUser extends Form
{
    use LazyWidget;
    /**
     * Handle the form request.
     *
     * @param array $input
     *
     * @return mixed
     */
    public function handle(array $input)
    {
        //dump($input);

        // return $this->response()->error('Your error message.');

        TongUser::query()->where('id',$input['id'])->update(['status'=>$input['status']]);
        return $this
            ->response()
            ->success('设置成功')
            ->refresh();
    }

    /**
     * Build a form here.
     */
    public function form()
    {
        $this->hidden('id','id')->required();
        $this->radio('status','是否禁用')->options([1 => '正常', 2=>'禁用']);
    }

    /**
     * The data of the form.
     *
     * @return array
     */
    public function default()
    {
        return [
            'id'=>$this->payload['id'] ?? null,
            'status'  => $this->payload['status'] ?? null,
        ];
    }
}
